package Class.Homemade.damo0523.demo3;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 姚东名
 * Date: 2024-05-23
 * Time: 22:53
 */
public class test {
    public static void main(String[] args) {
        //对象的实例化
        Cycle cycle = new Cycle();
        Flower flower = new Flower();

        //向上转型
        Shape[] shapes = {cycle, cycle, flower, flower};

        for (int i = 0; i < shapes.length; i++) {
            //等价于：Shape shape = cycle;
            Shape shape = shapes[i];
            //等价于：cycle.draw();
            shape.draw();
        }

        System.out.println("=========");
        Shape shape = new Cycle();
        shape.draw();
    }
}
